//
//  ViewController.m
//  UI27-ArrayDataSource
//
//  Created by 韩旭 on 16/8/19.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"
#import "ArrayDataSource.h"
#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height

#define WIDETH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
#define COLORAUTO [UIColor colorWithRed:(arc4random()%256/255.0) green:(arc4random()%256/255.0) blue:(arc4random()%256/255.0) alpha:1.0]

@interface ViewController ()<UITableViewDelegate>
@property (nonatomic, strong) NSArray *arr;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) ArrayDataSource *arrDataSource;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.arr = @[@"唐益梦", @"张合尉", @"高雅馨", @"符淋淋", @"孙遥", @"李毅然", @"于瀚", @"沙长健", @"卢思彤", @"徐昊", @"曹冠雄", @"陈丹明", @"罗浩", @"肖扬", @"王道林", @"宫雪", @"李成", @"冀永金", @"姜浩", @"罗鹏飞", @"李昊林", @"郭宝", @"马峰", @"刘坦奇", @"殷明静", @"邓凯", @"徐康", @"王鍠", @"韩旭", @"杨睿", @"张信宝", @"姜程程", @"包铭礼", @"杜江", @"苗钧豪"]; 
      _arrDataSource = [ArrayDataSource arrayDataSourceWithTableViewCellReuse:@"ce" dataSource:_arr configCell:^(UITableViewCell * _Nonnull cell, id  _Nonnull model) {
          cell.textLabel.text = model;
          NSLog(@"%@", model);
      }];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight) style:0];
    self.tableView.backgroundColor = [UIColor whiteColor];
//    tableView 的数据源变更为自定义类
//    注意：所有的协议不一定只能指向执行self
    _tableView.delegate = self;
    _tableView.dataSource = _arrDataSource;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"ce"];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end